查看原文
其他

ChatGPT prompt 书写指南 🧭

renee创业狗 Renee 创业随笔
2024-10-10

之前分享了很多咒语对于 stable diffusion 的重要作用。chatGPT 也是一样,好的 prompt 可以帮助我们让 GPT 更好地为我们工作。

Prompt 结构

在构建提示时,需要考虑以下几个元素:

元素
说明
任务Task指示 GPT 要生成的内容类型
指令Instructions在生成内容时应遵循的原则
角色RoleGPT 需要扮演的角色,如律师或客服
关键词Seed-word需要强调的点

例子1:

  • Task: Generate a product description for a new smartphone
  • Instructions: The description should be informative, persuasive and highlight the unique features of the smartphone
  • Role: Marketing representative
  • Seed-word: "innovative"

提示语可以是:

As a marketing representative, generate an informative, persuasive product description that highlights the innovative features of the new smartphone. The smartphone has the following features [insert your features]

例子2:

  • Task: Generate a product review for a new laptop
  • Instructions: The review should be objective, informative and highlight the unique features of the laptop
  • Role: Tech expert
  • Seed-word: "powerful"

提示语可以是:

As a tech expert, generate an objective and informative product review that highlights the powerful features of the new laptop.

Seed-word 使用

上面的例子是通过 highlight 动词后面接了 seed-word,还有两种方式可以强化 Seed-word:

  1. seed-word: [insert your keyword]
  • Task: Generate a story about a dragon
  • Seed-word: "Dragon"

Please generate text based on the following seed-word: Dragon

  1. 使用引号 that is related to the seed word '[insert your keyword]'
  • Task: Generate a poem
  • Seed-word: “love”
  • Instructions: The poem should be written in the style of a sonnet.
  • Role: Poet

Generate a sonnet related to the seed word 'love' as a poet

几种 prompt 类型

1. Zero, One and Few Shot Prompting

我们之前讲 langchain 的时候用过 Few Shot Prompting

这个其实是给 GPT 提供各种例子的,告诉 GPT 我们想要的东东是什么样子:

  • Task: Write a product description for a new smartwatch

1.1 Zero Shot Prompting

Generate a product description for this new smartwatch with zero examples

1.2 One Shot Prompting

Generate a product comparison of this new smartphone with one example [latest iPhone]

1.3 Few Shot Prompting

Generate a product comparison of this new smartphone with few examples [3 other smartphones]

2. 自洽提示

可以提示模型生成与提供的输入一致的文本,对于事实核查、数据验证或文本生成中的一致性检查等任务非常有用。

Generate a product review that is consistent with the following product information [insert product information]

Complete the following sentence in a way that is consistent with the context provided [insert sentence] Please ensure the following text is self-consistent [insert your sentence]

通过自洽性提示,研究人员可以更好地评估模型的准确性、一致性和可靠性,并找出需要改进的领域。

3. 对抗提示

测试和评估算法性能的方法。被设计成在输入中包含一些难以理解、具有误导性或针对性弱点的信息,以此来挑战和揭示算法的局限性。GPT 由于它们的大规模训练数据和复杂性,往往更容易受到这类攻击的影响。

Generate text that is difficult to classify as [insert label]

Generate text that is difficult to classify as having the sentiment of [insert sentiment]

Generate text that is difficult to translate to [insert target language]

输入这个之后,你就会发现 GPT 开始胡说八道。通过使用对抗性提示,研究人员可以发现并改进现有算法的弱点,从而提高其性能和安全性。

其他一些实用咒语:

  1. 脑暴发散想法

Let’s think about this: [insert your topic]

Let's discuss [insert your topic]

这个可以 GPT 给你一些发散的想法💡

  1. 文本生成

Generate a story of at least 1000 words, including characters [insert characters] and a plot [insert plot] based on the following prompt [insert prompt]

Complete the following text [insert text] and make sure that it is coherent and consistent with the input text.

引导模型生成特定类型文本的输入📒

  1. 生成对话

Generate a professional and accurate dialogue for a customer service chatbot, when the customer asks about [insert topic]

Generate a conversation between the following characters [insert characters] in the following context [insert context]

这种技术对于对话生成、故事写作和聊天机器人开发等任务非常有用。💬

  1. 聚类

Group the following news articles into clusters based on topic: [insert articles]

Group the following scientific papers into clusters based on research area: [insert papers]

可以让模型根据某些特征或特点将相似的数据点分组在一起。🗂

  1. 情感分类

Perform sentiment analysis on the following customer reviews [insert reviews] and classify them as positive, negative, or neutral.

Perform sentiment analysis on the following product reviews [insert reviews] and classify them as positive, negative, or neutral.

允许模型确定文本的情绪色彩或态度,例如它是积极的、消极的还是中立的。😄

  1. 文本分类

Perform text classification on the following customer reviews [insert reviews] and classify them into different categories such as electronics, clothing and furniture based on their content.

Perform text classification on the following emails [insert emails] and classify them into different categories such as spam, important, or urgent based on their content and sender.

让模型将文本分成不同的类别。和情感分析是不同的。情感分析特别关注于确定文本中表达的情感或情绪。这可能包括确定文本表达了积极、消极还是中性的情感。情感分析通常用于客户评论、社交媒体帖子和其他需要表达情感的文本。⭐️

  1. 命名实体识别

Perform named entity recognition on the following news article [insert article] and identify and classify people, organizations, locations, and dates.

Perform named entity recognition on the following research paper [insert paper] and identify and classify people, organizations, locations, and dates.

使模型识别和分类文本中的命名实体,例如人名、组织机构、地点和日期等。🗺️

以上就是各种 prompt 的结构、使用方法以及一些实用的示例。希望对大家有帮助。之后可以再试试用 https://flowgpt.com/ 这种更复杂的工具来生成更高级的 prompt。

参考书目:The Art of Asking ChatGPT for High-Quality Answers: A Complete Guide to Prompt Engineering Techniques (Making Money with ChatGPT) Paperback – January 25, 2023


继续滑动看下一个
Renee 创业随笔
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存